package jgenerator;

import javax.swing.JOptionPane;

public class Launcher {
	public static void main(String argv[]){
		//We popup as long as the user doesn't provide int values
		int nbItems;
		while(-1==(nbItems = Launcher.launchSplashScreen())){
			//nbItems = Launcher.launchSplashScreen();
		}
		new GeneratorGUI(nbItems);
	}/** static void main **/
	
	//This function allows to provide a splash screen for the user, 
	//allowing him to provide how many fields he needs
	public static int launchSplashScreen(){
		String nbBlocs = JOptionPane.showInputDialog(null, "Please indicate how many \r\n fields you need", "Number of field required", JOptionPane.QUESTION_MESSAGE);
		try{
			 int nbBlocsInt = Integer.parseInt(nbBlocs);//Conversion into a number
			 return nbBlocsInt;
		}catch(NumberFormatException e){
			launchErrorScreen();
			return -1;
		 }
	}/** launchSplashScreen **/
	
	public static void launchErrorScreen(){
		JOptionPane.showMessageDialog(null,
			    "Please input an integer value",
			    "Parsing error",
		    JOptionPane.ERROR_MESSAGE);
	}/** launchErrorScreen **/

}/**Launcher.java**/